import os
import subprocess
import json
import execjs

_dir = os.path.dirname(os.path.abspath(__file__))

# 执行Node.js脚本
output = subprocess.check_output(['node', os.path.join(_dir, 'async_code.js')], text=True)

# 解析结果
result = json.loads(output)
print("获取到的数据:", output)

with open(os.path.join(_dir, 'async_code2.js'), encoding='utf-8') as f:
        js_code = f.read()

js = execjs.compile(js_code)
result = js.call('get_data')
print("获取到的数据:", result)